<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script>
function t(){
	var o = document.getElementById('file');
	var file = o.files[0];
	var xhr = new XMLHttpRequest();
									
	xhr.upload.onprogress = function(e){
		if(e.lengthComputable){
			alert(e);
		}
	};

	xhr.onreadystatechange = function(){            
		if (xhr.readyState == 4){
			alert('ok');
		}
	};

	xhr.open("POST", '/file.php', true);
	xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
	xhr.setRequestHeader("Content-Type", "application/octet-stream");
	xhr.send(file);
}
</script>
<body>
<input type="file" id="file" multiple="multiple" />
<input type="button" onclick="t();" />
</body>
</html>
